package com.soulmate.order.service;

import common.pojo.Order;
import com.soulmate.order.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper=null;

    @Override
    public void addOrder(Order order) {
        //补齐数据
        order.setOrderId(UUID.randomUUID().toString());
        order.setOrderPaystate(0);//0表示未支付
        order.setOrderTime(new Date());
        orderMapper.insertOrderAndOrderItem(order);// insert into t_order
    }

    @Override
    public List<Order> queryMyOrders(String userId) {
        System.out.println("进入查询");
        List<Order> orderList=orderMapper.queryMyOrders(userId);
        return orderList;
    }

    @Override
    public void deleteOrder(String orderId) {
        orderMapper.deleteOrder(orderId);
    }
}
